//
//  WebMapViewController.m
//  NewApp
//
//  Created by xueyan liu on 7/8/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "WebMapViewController.h"
#import "AppDelegate.h"

#define DEFAULT_ZOOM_LEVEL	17

@interface WebMapViewController ()

@end

@implementation WebMapViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    int width = (int) webView.frame.size.width;
    int height = (int) webView.frame.size.height;
    
    NSString *urlStr = [NSString stringWithFormat:@"http://map.google.com", width, height,DEFAULT_ZOOM_LEVEL];
      
    NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]];//创建NSURLRequest    
    [webView loadRequest:request];//加载    
    
    NSArray *views = [self.tabBarController.view subviews];
    
    for(id viewId in views)
    {
        NSLog(@"viewId = %@", viewId);
        if([viewId isKindOfClass:[UITabBar class]])
        {
            [(UITabBar*)viewId setHidden:YES];
        }
        else 
        {
            [(UIView*)viewId setFrame:CGRectMake(0, 0, 320, 480)];
        }
    }
    [self.view setFrame:CGRectMake(0, 0, 320, 480)];
    
        //[self.view setFrame:CGRectMake(0, 0, 320, 480)];
 
    // Do any additional setup after loading the view from its nib.
}

- (void) viewWillDisappear:(BOOL)animated{
    
    NSArray *views = [self.tabBarController.view subviews];
    for(id viewId in views)
    {
        NSLog(@"viewId = %@", viewId);
        if([viewId isKindOfClass:[UITabBar class]])
        {
            [(UITabBar*)viewId setHidden:NO];
        }
    }

}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
